package com.hancher.gamelife2.matter;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.RawQuery;
import androidx.room.Update;
import androidx.sqlite.db.SupportSQLiteQuery;

import java.util.List;

/**
 * 描述 :  <br/>
 * 时间 : 2023/12/2 13:26 <br/>
 * 作者 : Hancher ytu_shaoweijie@163.com
 */
@Dao
public interface IMatterDao {
    @Insert
    void insertItem(MatterPO data);

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    void insertList(List<MatterPO> datas);

    @Delete
    void deleteItem(MatterPO data);

    @Update
    void updateItem(MatterPO data);

    @Update
    void updateList(List<MatterPO> datas);

    @RawQuery
    List<MatterPO> getFinishedList(SupportSQLiteQuery sql);

    @Query("SELECT count(*) FROM matter WHERE deleteflag!=1 AND finishTime BETWEEN :start AND :end")
    Integer getAllCountOnTime(Long start, Long end);

    @Query("SELECT count(*) FROM matter WHERE deleteflag!=1 AND finishTime BETWEEN :start AND :end AND status=1")
    Integer getFinishedCountOnTime(Long start, Long end);

    @Query("SELECT count(*) FROM matter WHERE deleteflag!=1")
    Integer getAllCount();

    @Query("SELECT count(*) FROM matter WHERE deleteflag!=1 AND status=1")
    Integer getFinishedCount();
}
